<template>
  <div>
    <a-card :bordered="false">
      <f-table ref="table" rowKey="optlogId" :columns="columns"  :multiple="true" :operator="operator" :params="queryParam" :api="api.optlog">
        <span slot="action" slot-scope="text, record">
          <template>
            <a @click="$refs.drawer.showDrawer(record)">编辑</a>
            <a-divider type="vertical"/>
          </template>
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
            <a-menu slot="overlay">
              <a-menu-item v-if="$auth('table.delete')">
                <a href="javascript:;" @click="$refs.table.del(record)">删除</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </f-table>
      <optlog-drawer ref="drawer"></optlog-drawer>
    </a-card>
  </div>
</template>
<script>
  import optlogDrawer from './optlog_drawer.vue'
  import api from './js/api'
  export default {
    name: 'TableList',
    components: {
      optlogDrawer
    },
    data() {
      let me = this
      //操作按钮
      let operator = []
      operator.push({
        name: '添加',
        icon: 'plus',
        that: this,
        handler: function(table, that) {
            that.$refs.drawer.showDrawer()
        }
      })
      operator.push({
        name: '删除',
        icon: 'delete',
        batch: true,
        handler: function(table) {
            table.remove()
        }
      })
      return {
        api:  Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {},
        // 表头
        columns: [
          {
            title: '#',
            width: '60',
            align: 'center',
            customRender: (text, record, index) => index + 1
          },
          {
            title: '操作类型',
            align: 'center',
            dataIndex: 'optType'
          },
          {
            title: '业务类型',
            align: 'center',
            dataIndex: 'busType'
          },
          {
            title: '操作值',
            align: 'center',
            dataIndex: 'content'
          },
          {
            title: '操作人',
            align: 'center',
            dataIndex: 'userId'
          },
          {
            title: '业务Id',
            align: 'center',
            dataIndex: 'businessId'
          },
          {
            title: '',
            align: 'center',
            dataIndex: 'optIp'
          },
          {
            title: '是否删除',
            align: 'center',
            dataIndex: 'deleted'
          },
          {
            title: '更新人',
            align: 'center',
            dataIndex: 'updateUser'
          },
          {
            title: '更新时间',
            align: 'center',
            dataIndex: 'updateTime'
          },
          {
            title: '创建人',
            align: 'center',
            dataIndex: 'createUser'
          },
          {
            title: '创建时间',
            align: 'center',
            dataIndex: 'createTime'
          },
          {
            title: '操作',
            align: 'center',
            scopedSlots: { customRender: 'action' }
          }
        ],
        operator: operator
      }
    },
    created() {
    },
    methods: {
    }
  }
</script>
